<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../../../bangnuo/admin/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../../../../bangnuo/admin/style/admin.css" media="all">
	</head>

	<body>
		<form class="layui-form" action="">
			<div class="layui-form-item">
				<label class="layui-form-label">门头照</label>
				<div class="layui-input-block">
					<button type="button" class="layui-btn" id="permissionsPictureDoor"><i class="layui-icon">&#xe67c;</i>上传图片 </button>
					<span id="permissionsPictureDoor1"></span>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">店内照</label>
				<div class="layui-input-block">
					<button type="button" class="layui-btn" id="permissionsPictureStore"><i class="layui-icon">&#xe67c;</i>上传图片 </button>
					<span id="permissionsPictureStore1"></span>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">收银台照</label>
				<div class="layui-input-block">
					<button type="button" class="layui-btn" id="permissionsPictureCheckstand"><i class="layui-icon">&#xe67c;</i>上传图片 </button>
					<span id="permissionsPictureCheckstand1"></span>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">身份证照（正）</label>
				<div class="layui-input-block">
					<button type="button" class="layui-btn" id="permissionsPictureCardPositive"><i class="layui-icon">&#xe67c;</i>上传图片 </button>
					<span id="permissionsPictureCardPositive1"></span>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">身份证照（反）</label>
				<div class="layui-input-block">
					<button type="button" class="layui-btn" id="permissionsPictureCardReverse"><i class="layui-icon">&#xe67c;</i>上传图片 </button>
					<span id="permissionsPictureCardReverse1"></span>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">手持身份证照</label>
				<div class="layui-input-block">
					<button type="button" class="layui-btn" id="permissionsPictureHandheld"><i class="layui-icon">&#xe67c;</i>上传图片 </button>
					<span id="permissionsPictureHandheld1"></span>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">银行卡照</label>
				<div class="layui-input-block">
					<button type="button" class="layui-btn" id="permissionsPictureBank"><i class="layui-icon">&#xe67c;</i>上传图片 </button>
					<span id="permissionsPictureBank1"></span>
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">营业执照</label>
				<div class="layui-input-block">
					<button type="button" class="layui-btn" id="permissionsPictureBusiness"><i class="layui-icon">&#xe67c;</i>上传图片 </button>
					<span id="permissionsPictureBusiness1"></span>
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">资质许可证</label>
				<div class="layui-input-block">
					<button type="button" class="layui-btn" id="permissionsPictureQualification"><i class="layui-icon">&#xe67c;</i>上传图片 </button>
					<span id="permissionsPictureQualification1"></span>
				</div>
			</div>

		</form>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit lay-filter="qualification-form">立即提交</button>
			</div>
		</div>
	</body>
	<script src="../../../../bangnuo/admin/layui/layui.js"></script>
	<script src="../../../../bangnuo/admin/js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript">
		layui.use(['form', 'upload'], function() {
            var url = window.location.href;
            //获取“=”的下标
            var pos = url.indexOf("=");
            //获取“=”后的全部字符（用户id）
            var id = url.substring(pos+1,url.length);
		    var imageList = {};
			var form = layui.form,
				upload = layui.upload;
			//监听提交
			form.on('submit(qualification-form)', function(data) {
                $.ajax({
                    url : "/commercial/updateImage/"+id,
                    contentType:"application/json;charset=UTF-8",
                    type : "POST",
                    data: JSON.stringify(imageList),
					dataType:"json",
                    success : function(res){
						if(res.success){
						    console.log("图片资源更新成功",res);
                            var  index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                            console.log("index值",index)
                            close();
						}else{
                            console.log("图片资源更新失败",res);
						}
                    }
                });
			});
			//门头照
			var uploadInst = upload.render({
				elem: '#permissionsPictureDoor' //绑定元素
					,
				url: '/upload/img' //上传接口
					,
				done: function(res) {
				    if(res.success){
                        console.log("上传成功",res);
                        $("#permissionsPictureDoor1").html("上传成功");
                        imageList.permissionsPictureDoor = res.object.webPath;
					}else{
                        $("#permissionsPictureDoor").html("上传失败，请重新上传");
					}

				},
				error: function() {
                    $("#permissionsPictureDoor1").html("上传失败，请重新上传");
				}
			});

            //店内照
            var uploadInst = upload.render({
                elem: '#permissionsPictureStore' //绑定元素
                ,
                url: '/upload/img' //上传接口
                ,
                done: function(res) {
                    if(res.success){
                        console.log("上传成功",res);
                        $("#permissionsPictureStore1").html("上传成功");
                        imageList.permissionsPictureStore = res.object.webPath;
                    }else{
                        $("#permissionsPictureStore1").html("上传失败，请重新上传");
                    }

                },
                error: function() {
                    $("#permissionsPictureStore1").html("上传失败，请重新上传");
                }
            });

            //收银台照
            var uploadInst = upload.render({
                elem: '#permissionsPictureCheckstand' //绑定元素
                ,
                url: '/upload/img' //上传接口
                ,
                done: function(res) {
                    if(res.success){
                        console.log("上传成功",res);
                        $("#permissionsPictureCheckstand1").html("上传成功");
                        imageList.permissionsPictureCheckstand = res.object.webPath;
                    }else{
                        $("#permissionsPictureCheckstand1").html("上传失败，请重新上传");
                    }

                },
                error: function() {
                    $("#permissionsPictureCheckstand1").html("上传失败，请重新上传");
                }
            });

            //身份证照正
            var uploadInst = upload.render({
                elem: '#permissionsPictureCardPositive' //绑定元素
                ,
                url: '/upload/img' //上传接口
                ,
                done: function(res) {
                    if(res.success){
                        console.log("上传成功",res);
                        $("#permissionsPictureCardPositive1").html("上传成功");
                        imageList.permissionsPictureCardPositive = res.object.webPath;
                    }else{
                        $("#permissionsPictureCardPositive1").html("上传失败，请重新上传");
                    }

                },
                error: function() {
                    $("#permissionsPictureCardPositive1").html("上传失败，请重新上传");
                }
            });

            //身份证照反
            var uploadInst = upload.render({
                elem: '#permissionsPictureCardReverse' //绑定元素
                ,
                url: '/upload/img' //上传接口
                ,
                done: function(res) {
                    if(res.success){
                        console.log("上传成功",res);
                        $("#permissionsPictureCardReverse1").html("上传成功");
                        imageList.permissionsPictureCardReverse = res.object.webPath;
                    }else{
                        $("#permissionsPictureCardReverse1").html("上传失败，请重新上传");
                    }

                },
                error: function() {
                    $("#permissionsPictureCardReverse1").html("上传失败，请重新上传");
                }
            });


            //手持身份证照
            var uploadInst = upload.render({
                elem: '#permissionsPictureHandheld' //绑定元素
                ,
                url: '/upload/img' //上传接口
                ,
                done: function(res) {
                    if(res.success){
                        console.log("上传成功",res);
                        $("#permissionsPictureHandheld1").html("上传成功");
                        imageList.permissionsPictureHandheld = res.object.webPath;
                    }else{
                        $("#permissionsPictureHandheld1").html("上传失败，请重新上传");
                    }

                },
                error: function() {
                    $("#permissionsPictureHandheld1").html("上传失败，请重新上传");
                }
            });


            //银行卡照
            var uploadInst = upload.render({
                elem: '#permissionsPictureBank' //绑定元素
                ,
                url: '/upload/img' //上传接口
                ,
                done: function(res) {
                    if(res.success){
                        console.log("上传成功",res);
                        $("#permissionsPictureBank1").html("上传成功");
                        imageList.permissionsPictureBank = res.object.webPath;
                    }else{
                        $("#permissionsPictureBank1").html("上传失败，请重新上传");
                    }

                },
                error: function() {
                    $("#permissionsPictureBank1").html("上传失败，请重新上传");
                }
            });


            //营业执照
            var uploadInst = upload.render({
                elem: '#permissionsPictureBusiness' //绑定元素
                ,
                url: '/upload/img' //上传接口
                ,
                done: function(res) {
                    if(res.success){
                        console.log("上传成功",res);
                        $("#permissionsPictureBusiness1").html("上传成功");
                        imageList.permissionsPictureBusiness = res.object.webPath;
                    }else{
                        $("#permissionsPictureBusiness1").html("上传失败，请重新上传");
                    }

                },
                error: function() {
                    $("#permissionsPictureBusiness1").html("上传失败，请重新上传");
                }
            });


            //资质许可证
            var uploadInst = upload.render({
                elem: '#permissionsPictureQualification' //绑定元素
                ,
                url: '/upload/img' //上传接口
                ,
                done: function(res) {
                    if(res.success){
                        console.log("上传成功",res);
                        $("#permissionsPictureQualification1").html("上传成功");
                        imageList.permissionsPictureQualification = res.object.webPath;
                    }else{
                        $("#permissionsPictureQualification1").html("上传失败，请重新上传");
                    }

                },
                error: function() {
                    $("#permissionsPictureQualification1").html("上传失败，请重新上传");
                }
            });



		});
	</script>

</html>